#!/usr/bin/perl -w

use English;

# hash of hashes

sub myprint {
	print "-" x 40 . "\n";
	for $iso (sort keys %hoh) {
		print "$iso: ";
		for $attr (sort keys %{ $hoh{$iso} } ) {
			print "$attr=$hoh{$iso}{$attr} ";
		}
		print "\n";
	}
}

# Anlegen eines Hash of Hashes
%hoh = (
	EUR => { name => "Euro", kurs => 1 },
	USD => { name => "US-Dollar", kurs => 1.1975 }
);
myprint;

# Hinzufuegen eines Elementes
$hoh{GBP} = { name => "Britische Pfund", kurs => 0.68 };
myprint;

# oder so
$hoh{JPY}{kurs} = 141;
$hoh{JPY}{name} = "Yen";
myprint;

# Einlesen aus Datei

open (IN,"hoh.txt") or die "open";
while (<IN>) {
	chomp;
	($iso, $line) = split /:/,$_,2;
	for $field ( split /:/,$line ) {
		($key, $value) = split /=/, $field;
		$hoh{$iso}{$key} = $value;
	}
}
close IN;

# Hinzufuegen von Attributen
$hoh{CHF}{land} = "Schweiz";
myprint;
